<?php
/*------------------------------------------------------+
| PHP-Fusion Content Management System                  |
| Copyright (C) 2002 - 2010 Nick Jones                  |
| http://www.php-fusion.co.uk/                          |
+-------------------------------------------------------+
| This program is released as free software under the   |
| Affero GPL license. You can redistribute it and/or    |
| addonify it under the terms of this license which you |
| can read by viewing the included agpl.txt or online   |
| at www.gnu.org/licenses/agpl.html. Removal of this    |
| copyright header is strictly prohibited without       |
| written permission from the original author(s).       |
+------------------------------------------------------*/
/*------------------------------------------------------+
|     Theme TLC for PHP-Fusion v7                       |
+-------------------------------------------------------+
| Filename: theme.php                                   |
| Author: Harly Petersen                                |
| Homepage: http://php-fusion.openworld.dk/             |
+-------------------------------------------------------+
| This theme is released under the terms and conditions |
| of the GNU Affero GPL v3.                             |
+------------------------------------------------------*/
if (!defined("IN_FUSION")) { die("Access Denied"); }

define("THEME_BULLET", "<img class='bullet' src='".THEME."images/bullet.gif' alt='bullet.gif' border='0'/>");

define("THEME_WIDTH", "100%");

require_once INCLUDES."theme_functions_include.php";

function render_page($license=false) {
	
	global $settings, $main_style, $locale, $aidlink, $userdata;

if (file_exists(THEME."locale/".$settings['locale'].".php")) {
	include THEME."locale/".$settings['locale'].".php";
} else {
	include THEME."locale/English.php";
}

//Header
echo "<table cellspacing='0' cellpadding='0' width='".THEME_WIDTH."' align='center'>";
echo "<tr>";
echo "<td class='border-left'></td>";
echo "<td class='full-header' align='center'>\n".showbanners()."</td>";
echo "<td align='right' class='border-right'></td>";
echo "</tr>";
echo "</table>\n";
echo "<table cellpadding='0' cellspacing='0' width='".THEME_WIDTH."' align='center'>";
echo "<tr>";
echo "<td class='header-btm-left'></td>";
echo "<td class='header-btm' width='20%' valign='middle'>";
echo "<form name='Tick' action='".FUSION_SELF."'>
<input type='text' class='clock' size='12' name='Clock' style='width:100px;'/>
</form>
<script type='text/Javascript'>
<!--
/*By George Chiang (JK's JavaScript tutorial)
http://javascriptkit.com
Credit must stay intact for use*/
function show(){
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn='AM'
if (hours>12){
dn='PM'
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes='0'+minutes
if (seconds<=9)
seconds='0'+seconds
document.Tick.Clock.value=hours+':'+minutes+':'
+seconds+' '+dn
setTimeout('show()',1000)
}
show()
//-->
</script>";
echo "<noscript><p>Enable Javascript to see the clock.</p></noscript>";
echo "</td>";

if (iMEMBER)
{
$msg_count = dbcount("(message_id)", DB_MESSAGES, "message_to='".$userdata['user_id']."' AND message_read='0'AND message_folder='0'");

        echo "<td class='header-btm' align='right'>
        <div id='menu'>
        <ul>
        <li><a id='logout' href='".BASEDIR."setuser.php?logout=yes' title='".$locale['global_124']."'></a></li>
        ".(iADMIN ? "<li><a id='admin' href='".ADMIN."index.php".$aidlink."' title='".$locale['global_123']."'></a></li> \n" : "")."
        <li><a id='userlist' href='".BASEDIR."members.php' title='".$locale['global_122']."'></a></li>
        <li><a id='profile' href='".BASEDIR."edit_profile.php' title='".$locale['global_120']."'></a></li>
        <li><a id='pm' href='".BASEDIR."messages.php' title='".$locale['global_121']."'></a></li>
        <li><a href='".BASEDIR."messages.php'>";if ($msg_count){echo"&nbsp;<span id='msgcount'>[$msg_count]</span>";}echo"</a></li>
        </ul>
        </div>
        </td>";
}
else
{
echo "<td class='header-btm' align='center' valign='middle'>";
echo "".(isset($loginerror) ? $loginerror : "")."
<form name='loginform2' method='post' action='".FUSION_SELF."'>
".$locale['global_101'].":&nbsp;
<input type='text' name='user_name' class='textbox' style='width:100px;'/>&nbsp;
".$locale['global_102'].":&nbsp;
<input type='password' name='user_pass' class='textbox' style='width:100px;'/>&nbsp;
<input type='submit' name='login' value='".$locale['global_104']."' class='button2'/>
</form></td>";
echo "<td class='header-btm' align='right' valign='middle' width='20%'>
      <div id='menu'>
        <ul>
        <li><a id='lp' href='".BASEDIR."lostpassword.php' title='".$locale['global_108']."'></a></li>
        ".($settings['enable_registration'] ? "<li><a id='register' href='".BASEDIR."register.php' title='".$locale['global_107']."'></a></li> \n" : "")."
        </ul>
      </div>
      </td>";
}

echo "<td align='right' class='header-btm-right'></td>";
echo "</tr>";
echo "</table>";
echo "<div class='spacer2'></div>\n";

        //Sub-Header
	echo "<table cellpadding='0' cellspacing='0' align='center'>";
	echo "<tr>";
	echo "<td>";
        include THEME."TinyDropdown/tinydropdown.php";
	echo "</td>\n";
	echo "</tr>\n</table>\n";

	//Content
	echo "<table cellpadding='0' cellspacing='0' width='".THEME_WIDTH."' align='center'>";
	echo "<tr>";
	echo "<td><img src='".THEME."images/center-left.png' alt='center-left.png' /></td>\n";
	echo "<td class='content' style='width:100%;'></td>\n";
	echo "<td align='right'><img src='".THEME."images/center-right.png' alt='center-right.png' /></td>\n";
	echo "</tr>\n</table>\n";
	echo "<table cellpadding='0' cellspacing='0' width='".THEME_WIDTH."' align='center'>";
	echo "<tr>";
	echo "<td class='border-left'></td>";
	if (LEFT) { echo "<td class='side-border-left' valign='top'>".LEFT."</td>"; }
        echo "<td class='main-bg' valign='top'>".U_CENTER.CONTENT.L_CENTER."</td>";
	if (RIGHT) { echo "<td class='side-border-right' valign='top'>".RIGHT."</td>"; }
	echo "<td align='right' class='border-right'></td>";
	echo "</tr>\n";
	echo "</table>\n";
	echo "<table cellspacing='0' cellpadding='0' width='".THEME_WIDTH."' align='center'>";
	echo "<tr>";
	echo "<td><img src='".THEME."images/centerb-left.png' alt='centerb-left.png' /></td>\n";
	echo "<td class='centerb' style='width:100%;'></td>\n";
	echo "<td align='right'><img src='".THEME."images/centerb-right.png' alt='centerb-right.png' /></td>\n";
	echo "</tr>\n";
	echo "</table>\n";
	echo "<div class='spacer2'></div>\n";
	
	//Footer
	echo "<table cellpadding='0' cellspacing='0' width='".THEME_WIDTH."' align='center'>";
	echo "<tr>";
	echo "<td><img src='".THEME."images/center-left.png' alt='center-left.png' /></td>\n";
	echo "<td class='content' style='width:100%;'></td>\n";
	echo "<td align='right'><img src='".THEME."images/center-right.png' alt='center-right.png' /></td>\n";
	echo "</tr>\n</table>\n";
	echo "<table cellpadding='0' cellspacing='0' width='".THEME_WIDTH."' align='center'>";
	echo "<tr>";
	echo "<td class='border-left'></td>";
	echo "<td align='center' class='main-footer' valign='top'>".stripslashes($settings['footer'])."</td>";
	echo "<td align='right' class='border-right'></td>";
	echo "</tr>\n";
	echo "</table>\n";
	echo "<table cellpadding='0' cellspacing='0' width='".THEME_WIDTH."' align='center'>";
	echo "<tr>";
	echo "<td class='footer-left'></td>\n";
	echo "<td align='left' class='footer' style='width:20%;' valign='middle'>".showcounter()."</td>\n";
	echo "<td align='center' class='footer' valign='middle'>";
	if (!$license) { echo "\n".showcopyright(); }
	echo "</td>\n";
	echo "<td align='right' class='footer' style='width:20%;' valign='middle'><p style='margin:0;'>Theme <b>TLC</b> by <a href='http://php-fusion.openworld.dk' target='_blank'>Harly</a></p></td>";
	echo "<td align='right' class='footer-right'></td>\n";
	echo "</tr>\n</table>\n";
	echo "<table cellspacing='0' cellpadding='0' width='".THEME_WIDTH."' align='center'>";
	echo "<tr>";
	echo "<td><img src='".THEME."images/centerb-left.png' alt='centerb-left.png' /></td>\n";
	echo "<td class='centerb' style='width:100%;'></td>\n";
	echo "<td align='right'><img src='".THEME."images/centerb-right.png' alt='centerb-right.png' /></td>\n";
	echo "</tr>\n";
	echo "</table>\n";

}

function render_news($subject, $news, $info) {

	echo "<table cellpadding='0' cellspacing='0' style='width:100%;'>";
	echo "<tr>";
	echo "<td class='capmain-left'></td>\n";
	echo "<td class='capmain'>".$subject."</td>\n";
	echo "<td align='right' class='capmain-right'></td>\n";
	echo "</tr>\n";
	echo "</table>\n";
	echo "<table width='100%' cellpadding='0' cellspacing='0'>";
	echo "<tr>";
	echo "<td class='purple-left'></td>";
	echo "<td class='main-body middle-border'>".$news."</td>\n";
	echo "<td align='right' class='purple-right'></td>";
	echo "</tr>\n<tr>\n";
	echo "<td class='purple-left'></td>";
	echo "<td align='center' class='news-footer middle-border'>\n";
	echo newsposter($info," &middot;").newsopts($info,"&middot;").itemoptions("N",$info['news_id']);
	echo "</td>\n";
	echo "<td align='right' class='purple-right'></td>";
	echo "</tr>\n";
	echo "</table>\n";
	echo "<table cellspacing='0' cellpadding='0' style='width:100%;'>";
	echo "<tr>";
	echo "<td><img src='".THEME."images/purple-btm-left.png' alt='purple-btm-left.png' /></td>\n";
	echo "<td class='purple-btm' style='width:100%;'></td>\n";
	echo "<td align='right'><img src='".THEME."images/purple-btm-right.png' alt='purple-btm-right.png' /></td>\n";
	echo "</tr>\n";
	echo "</table>\n";
	echo "<div class='spacer'></div>\n";

}

function render_article($subject, $article, $info) {

	echo "<table cellpadding='0' cellspacing='0' style='width:100%;'>";
	echo "<tr>";
	echo "<td class='capmain-left'></td>\n";
	echo "<td class='capmain'>".$subject."</td>\n";
	echo "<td align='right' class='capmain-right'></td>\n";
	echo "</tr>\n";
	echo "</table>\n";
	echo "<table width='100%' cellpadding='0' cellspacing='0'>\n<tr>\n";
	echo "<td class='purple-left'></td>";
	echo "<td class='main-body middle-border'>".($info['article_breaks'] == "y" ? nl2br($article) : $article)."</td>\n";
	echo "<td align='right' class='purple-right'></td>";
	echo "</tr>\n<tr>\n";
	echo "<td class='purple-left'></td>";
	echo "<td align='center' class='news-footer middle-border'>\n";
	echo articleposter($info," &middot;").articleopts($info,"&middot;").itemoptions("A",$info['article_id']);
	echo "</td>\n";
	echo "<td align='right' class='purple-right'></td>";
	echo "</tr>\n";
	echo "</table>\n";
	echo "<table cellspacing='0' cellpadding='0' style='width:100%;'>";
	echo "<tr>";
	echo "<td><img src='".THEME."images/purple-btm-left.png' alt='purple-btm-left.png' /></td>\n";
	echo "<td class='purple-btm' style='width:100%;'></td>\n";
	echo "<td align='right'><img src='".THEME."images/purple-btm-right.png' alt='purple-btm-right.png' /></td>\n";
	echo "</tr>\n";
	echo "</table>\n";
	echo "<div class='spacer'></div>\n";
}

function opentable($title, $collapse = false, $state = "on") {

	global $panel_collapse; $panel_collapse = $collapse;
	
	echo "<table cellpadding='0' cellspacing='0' style='width:100%;'>\n<tr>\n";
	echo "<td class='capmain-left'></td>\n";
	echo "<td class='capmain'>$title</td>\n";
	if ($collapse == true) {
		$boxname = str_replace(" ", "", $title);
		echo "<td class='capmain' align='right'>".panelbutton($state, $boxname)."</td>\n";
	}
	echo "<td align='right' class='capmain-right'></td>\n";
	echo "</tr>\n</table>\n";
	echo "<table cellpadding='0' cellspacing='0' style='width:100%;'>\n<tr>\n";
	echo "<td class='purple-left'></td>";
	echo "<td class='main-body'>\n";	
	if ($collapse == true) { echo panelstate($state, $boxname); }

}

function closetable() {

	global $panel_collapse;

	if ($panel_collapse == true) { echo "</div>\n"; }
	echo "</td>\n";
	echo "<td align='right' class='purple-right'></td>";
	echo "</tr>\n";
	echo "</table>\n";
	echo "<table cellspacing='0' cellpadding='0' style='width:100%;'>";
	echo "<tr>";
	echo "<td><img src='".THEME."images/purple-btm-left.png' alt='purple-btm-left.png' /></td>\n";
	echo "<td class='purple-btm' style='width:100%;'></td>\n";
	echo "<td align='right'><img src='".THEME."images/purple-btm-right.png' alt='purple-btm-right.png' /></td>\n";
	echo "</tr>\n";
	echo "</table>\n";
	echo "<div class='spacer'></div>\n";

}

function openside($title, $collapse = false, $state = "on") {

	global $panel_collapse; $panel_collapse = $collapse;
	
	echo "<table cellpadding='0' cellspacing='0' style='width:100%;'>\n<tr>\n";
	echo "<td class='scapmain-left'></td>\n";
	echo "<td align='center' class='scapmain'>$title</td>\n";
	if ($collapse == true) {
		$boxname = str_replace(" ", "", $title);
		echo "<td class='scapmain' align='right'>".panelbutton($state, $boxname)."</td>\n";
	}
	echo "<td align='right' class='scapmain-right'></td>\n";
	echo "</tr>\n</table>\n";
	echo "<table cellpadding='0' cellspacing='0' style='width:100%;'>\n<tr>\n";
	echo "<td class='side-left'></td>";
	echo "<td class='side-body'>\n";	
	if ($collapse == true) { echo panelstate($state, $boxname); }
}

function closeside() {
	
	global $panel_collapse;

	if ($panel_collapse == true) { echo "</div>\n"; }
	echo "</td>\n";
	echo "<td align='right' class='side-right'></td>";
	echo "</tr>\n";
	echo "</table>\n";
	echo "<table cellspacing='0' cellpadding='0' style='width:100%;'>";
	echo "<tr>";
	echo "<td class='side-btm-left'><img src='".THEME."images/blank.gif' alt='blank.gif' style='display:block;width:10px;height:5px;' /></td>";
	echo "<td class='side-btm' style='width:100%;'></td>\n";
	echo "<td class='side-btm-right'><img src='".THEME."images/blank.gif' alt='blank.gif' style='display:block;width:10px;height:5px;' /></td>";
	echo "</tr>\n";
	echo "</table>\n";
	echo "<div class='spacer'></div>\n";

}

?>
